<!--
  @author heguanghua
  @since 2019/06/12 11:57
-->
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-4.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head th:include="common/common::jscss"/>
<body>

<div class="layui-fluid">

    <blockquote class="layui-crumb">
        渠道管理>
        <a lay-href="/channel/list.action">渠道管理</a>>
        <a th:href="'/channel/detail.action?channelId='+${obj.channelId}">[[${obj.name}]]</a>>
        <zmn text="服务区域">服务区域</zmn>
    </blockquote>

    <div class="layui-card">
        <div th:replace="channel/_tab::tab"></div>

        <fieldset class="layui-elem-field">
            <div class="layui-field-box" style="color: #9F9F9F;">
                未开通任何区域，表示开通：全国！若二级渠道的开通分类未设置，则此处将继承上级渠道配置；修改后会有5分钟缓存
            </div>
        </fieldset>

        <form method="POST" class="layui-form" action="/channel/service/area/list.action">
            <input type="hidden" name="addFlag" th:value="${addFlag}"/>
            <div th:replace="channel/servicearea/_query::query"></div>
        </form>

        <div class="layui-card-body">

            <div th:replace="channel/servicearea/_table::table"></div>

            <script type="text/html" id="zmn-table-tool">
                <div class="layui-btn-container">
                    <a th:if="${#authPermit.checkPermit('/channel/serviceArea/del.action') || (#authPermit.checkPermit('/channel/add.action') && addFlag == '1')}"
                       class="layui-btn layui-btn-sm layui-btn-danger" lay-event="remove">移除</a>
                    <a th:if="${#authPermit.checkPermit('/channel/serviceArea/addEdit.action') || (#authPermit.checkPermit('/channel/add.action') && addFlag == '1')}"
                       class="layui-btn layui-btn-sm layui-btn-primary" lay-event="add">+新增</a>
                    <a th:if="${#authPermit.checkPermit('/channel/serviceArea/addEdit.action') || (#authPermit.checkPermit('/channel/add.action') && addFlag == '1')}"
                       class="layui-btn layui-btn-sm layui-btn-primary" lay-event="batchSaveCategory">开通前台分类</a>
                </div>
            </script>

        </div>

    </div>

</div>
</body>
</html>

<script id="selectAreaHtml" type="text/html">
    <!--<div class="serachTable">-->
        <!--首字母：-->
        <!--<div class="layui-inline">-->
            <!--<input class="layui-input" name="firstLetter" id="firstLetter" autocomplete="off">-->
        <!--</div>-->
        <!--<button class="layui-btn" data-type="reload">搜索</button>-->
    <!--</div>-->
    <input type="hidden" id="parentId" name="parentId" value="{{d.parentId}}" />
    <table class="layui-hide" id="zmn-select-area-table" lay-filter="zmn-select-area-table">
        <thead >
        <tr>
            <th lay-data="{type:'checkbox', width:50, unresize:true, align:'center', fixed:'left'}"></th>
            <th lay-data="{field:'areaId', width:80, unresize:true, align:'center'}">区域ID</th>
            <th lay-data="{field:'name', width:150, unresize:true, align:'left'}">区域名称</th>
            <th lay-data="{field:'code', width:100, unresize:true, align:'left'}">区域代码</th>
            <th lay-data="{field:'firstLetter', width:80, unresize:true, align:'left'}">首字母</th>
            <th lay-data="{field:'操作', unresize:true, align:'center', fixed:'right', toolbar: '#zmn-select-area-table-bar'}">操作</th>
        </tr>
        </thead>
        <tbody>
        {{#  layui.each(d.items, function(index, item){ }}
        <tr>
            <td></td>
            <td>{{ item.areaId }}</td>
            <td>{{ item.name }}</td>
            <td>{{ item.code }}</td>
            <td>{{ item.firstLetter }}</td>
        </tr>
        {{#  }); }}
        </tbody>
    </table>
</script>

<script type="text/html" id="zmn-select-area-table-tool">
    <div class="layui-btn-container">

        <div class="layui-btn-group">
            <button class="layui-btn layui-btn-sm" lay-event="select">选择</button>
        </div>

        <div class="layui-btn-group">
            {{#if(currLevel == 0){ }}
            <button class="layui-btn layui-btn-sm layui-btn-primary" lay-event="selectAll">添加全国城市</button>
            {{#}}}
            {{#if(currLevel > 0){ }}
            <a lay-event="parent" class="layui-btn layui-btn-sm layui-btn-primary">返回上级区域</a>
            {{#}}}
        </div>

    </div>
</script>

<script type="text/html" id="zmn-select-area-table-bar">
    {{#if(currLevel < 3){ }}
    <a style="color: #00a0e9" lay-event="child" lay-text="查看下一级">查看下一级</a>
    {{#}}}
    {{#if(currLevel >= 3){ }}
    <a style="color: #00a0e9" lay-event="select" lay-text="选择">选择</a>
    {{#}}}
</script>

<script type="text/javascript" th:inline="javascript">

    let childIndex;

    let currLevel;

    var json = {
        totalCount: [[${query.totalCount}]],
        pageSize: [[${query.pageSize}]],
        pageIndex: [[${query.pageIndex}]],
        provinceId: [[${query.provinceId}]],
        cityId: [[${query.cityId}]],
        channelId: [[${query.channelId}]]
    };

    layui.config({
        base: "/static/lay/",
        version: 201910101439
    }).extend({
        index: "lib/index",
        channel_service_area_list: "channel/servicearea/zmn.channel.servicearea.list"
    }).use(['index', 'channel_service_area_list']);

</script>
